package com.joysuch.wwyt.workflow.service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.joysuch.wwyt.core.bean.SimpleSelectListBean;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.core.entity.BaseMenuFunction;
import com.joysuch.wwyt.core.exception.ApiBusinessException;
import com.joysuch.wwyt.core.exception.ApiCoreException;
import com.joysuch.wwyt.mh.entity.MhMonitoringType;
import com.joysuch.wwyt.monitoringcenter.bean.ScreenColumnBean;
import com.joysuch.wwyt.workflow.bean.*;
import com.joysuch.wwyt.workflow.entity.WorkFlowProcess;
import com.joysuch.wwyt.workflow.entity.WorkFlowProcessCodeStrategy;
import com.joysuch.wwyt.workflow.entity.WorkFlowTask;
import com.joysuch.wwyt.workflow.entity.bo.ComponentStatisticBO;
import org.activiti.engine.repository.Deployment;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;

public interface WorkFlowProcessService {
    Optional<WorkFlowProcess> findById(Long processId);

    String getModelId(Long processId) throws ApiBusinessException;

    WorkFlowEditModelBean getProcessModel(Long processId) throws ApiBusinessException;

    Page<WorkFlowProcess> findByPage(Pageable pageable);

    WorkFlowProcess add(WorkFlowProcessBean bean);

    void update(WorkFlowProcessBean bean);

    void saveComponentToCache(Long processId, String formJson, Long tenentId, String companyCode);

    void update(WorkFlowProcess entity);

    void saveProcessModelConfig(ProcessModelConfigBean bean) throws JsonProcessingException;

    void saveProcessFormConfig(ProcessFormConfigBean bean);

    void deleteById(Long id);

    void deleteMenuByMenuId(Long id);

    WorkFlowProcessBean findDetailById(Long processId);

    Deployment deployWorkFlowProcess(Long processId) throws IOException, ApiCoreException;

    WorkFlowProcess getByModelId(String modelId);

    List<BaseMenuFunction> listSystem();

    WorkFlowProcess findByBizName(String bizName);

    List<WorkFlowTaskNameBean> findTaskNameList(Long processId);

    List<WorkFlowProcessSimpleBean> findSimpleList();

    ResultBean dataSource(Integer type, Pageable pageable);

    ResultBean locationConfigSave(WorkFlowLocationConfigBean<WorkFlowScreenConfigBean, WorkFlowRailAlarmConfigBean> bean);

    ResultBean processLocationConfig(Long processId) throws ApiCoreException;

    ResultBean workFlowScreen(WorkFlowSearchBean searchMap);

    ResultBean workFlowScreenIconByCompany(String orgCode, Long tenentId,String bizName);

    ResultBean printTemplateSave(WorkFlowPrintTemplateBean bean);

    ResultBean printTemplateGet(Long processId);

    ResultBean screenTypeSave(WorkFlowScreenTypeBean bean);

    ResultBean screenTypePage(Pageable pageable);

    ResultBean screenTypeDelete(Long id);

    List<ScreenColumnBean> allColumn();

    ResultBean columnList(ScreenColumnBean screenColumnBean);

    ResultBean columnSave(ScreenColumnConfigBean bean);

    public void removeData(List<WorkFlowTaskSearchFieldBean> fieldList, Iterator<WorkFlowTask> iterator, String formData);

    List<Map<String,Object>> findAllProcessIdAndName();

    WorkFlowLocationConfigBean<WorkFlowScreenConfigBean, WorkFlowRailAlarmConfigBean> getLocationConfigByProcessId(Long processId);

    Map<Long,WorkFlowLocationConfigBean<WorkFlowScreenConfigBean, WorkFlowRailAlarmConfigBean>> getLocationConfigMapByProcessIds(List<Long> processIds);

    void saveConfigFromMhPointType(MhMonitoringType saveType);

    WorkFlowProcessCodeStrategy saveCodeStrategy(WorkFlowProcessCodeStrategyBean bean);

    WorkFlowProcessCodeStrategyBean findCodeStrategyById(Long id);

    void deleteEnvironmentPointConfig(MhMonitoringType type);

    ResultBean pageCodeStrategy(Pageable page,String name);

    ResultBean deleteCodeStrategyById(Long id);

    List<SimpleSelectListBean> getByBizTypeName(String bizTypeName);

    WorkFlowProcess getWorkFlowProcessByDefinitionKey(String definitionKey);

    List<WorkFlowProcess> findByBizNameList(String bizName);

    /**
     * 根据流程名称 获取配置的表单信息
     * @param processName
     * @return
     */
    List<ComponentStatisticBO> getFields(String processName);

    /**
     * 根据流程名称 获取配置的表单信息(流程引擎2.0)
     * @param processName
     * @return
     */
    List<ComponentStatisticBO> getV2Fields(String processName);
}
